<?php
namespace App\Utils\Logic\lak;
use App\Models\lak\Login;
use App\Utils\Lib\Redis;
use App\Models\Ly\wxLogin;
class Register
{
    /*
     * 注册
     * @lak
     * */
    public static function register($phone,$code){
        $PhoneNumber =  wxLogin::GetPhone(['phone' => $phone]);
        if ($PhoneNumber)  throw new \Exception('已注册');
        $redis = Redis::createRedisObject();
        $redis->select(2);
        $key = 'code'.$phone;
        $codes = $redis->GetRedis($key);
        if ($codes!=$code) throw new \Exception('验证码不对');
        $info=[
            'phone'=>$phone
        ];
        $res = wxLogin::Creat($info);
        $res=json_decode(json_encode($res),true);
        return $res;
    }

}
